package com.ease.framework.gef {
   import com.ease.util.collections.HashMap;
   import com.ease.util.collections.Map;
   import com.ease.common.models.IModel;
   import com.ease.framework.figures.IFigure;
   import com.ease.framework.gef.ui.SelectionManager;
   import com.ease.framework.gef4g.GraphicalBehavior;
   import com.ease.framework.gef4p.constant.DiagramConstant;
   import com.ease.framework.workbench.spi.impls.CommandStack;

   public class EditDomain {
      private var map_Model2EditPart:Map = new HashMap();

      private var map_figure2EditPart:Map = new HashMap();

      private var _commandStack:CommandStack;

      private var _selectionManager:SelectionManager;

      private var _behavior:GraphicalBehavior = new GraphicalBehavior();

      private var _viewModel:String = DiagramConstant.VIEW_TYPE_2D;

      public function EditDomain() {
         _commandStack = new CommandStack();
         _selectionManager = new SelectionManager();
      }

      public function pushFigure(figure:IFigure, editPart:IEditPart):void {
         map_figure2EditPart.put(figure, editPart);
      }

      public function pushModel(model:IModel, editPart:IEditPart):void {
         map_Model2EditPart.put(model, editPart);
      }

      public function getEditPartByModel(model:IModel):IEditPart {
         return map_Model2EditPart.getObject(model) as IEditPart;
      }

      public function getEditPartByFigure(figure:IFigure):IEditPart {
         return map_figure2EditPart.getObject(figure) as IEditPart;
      }

      public function getAllFigures():Array {
         return map_figure2EditPart.keys();
      }

      public function removeModelFromMap(model:IModel):void {
         map_Model2EditPart.remove(model);
      }

      public function removeFigureFromMap(figure:IFigure):void {
         map_figure2EditPart.remove(figure);
      }

      public function getCommandStack():CommandStack {
         return _commandStack;
      }

      public function getSelectionManager():SelectionManager {
         return _selectionManager
      }

      public function set behaviorType(value:int):void {
         _behavior.behaviorType = value;
      }

      public function get behaviorType():int {
         return _behavior.behaviorType;
      }

      public function set behaviorData(value:*):void {
         _behavior.behaviorData = value;
      }

      public function get behaviorData():* {
         return _behavior.behaviorData;
      }

      public function set viewModel(value:String):void {
         _viewModel = value;
      }

      public function get viewModel():String {
         return _viewModel;
      }

      public function clear():void {
         //将所有的map清空
         map_Model2EditPart.clear();
         map_figure2EditPart.clear();
      }

      public function getAllModels():Array {
         return map_Model2EditPart.keys();
      }

   }
}